package cn.iocoder.yudao.module.fengdong.smartelderly.dal.mysql.floorlevels;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.fengdong.smartelderly.dal.dataobject.floorlevels.FloorLevelsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.fengdong.smartelderly.controller.admin.floorlevels.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 楼号管理 Mapper
 *
 * @author 沣东养老院管理员
 */
@Mapper
public interface FloorLevelsMapper extends BaseMapperX<FloorLevelsDO> {

    default PageResult<FloorLevelsDO> selectPage(FloorLevelsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FloorLevelsDO>()
                .eqIfPresent(FloorLevelsDO::getParentId, reqVO.getParentId())
                .eqIfPresent(FloorLevelsDO::getSort, reqVO.getSort())
                .betweenIfPresent(FloorLevelsDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(FloorLevelsDO::getDetail, reqVO.getDetail())
                .eqIfPresent(FloorLevelsDO::getType, reqVO.getType())
                .orderByDesc(FloorLevelsDO::getId));
    }

    default List<FloorLevelsDO> selectList(FloorLevelsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<FloorLevelsDO>()
                .eqIfPresent(FloorLevelsDO::getParentId, reqVO.getParentId())
                .eqIfPresent(FloorLevelsDO::getSort, reqVO.getSort())
                .betweenIfPresent(FloorLevelsDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(FloorLevelsDO::getDetail, reqVO.getDetail())
                .eqIfPresent(FloorLevelsDO::getType, reqVO.getType())
                .orderByDesc(FloorLevelsDO::getId));
    }

    default FloorLevelsDO selectByParentIdAndName(Long parentId, String name){
        return selectOne(FloorLevelsDO::getParentId, parentId, FloorLevelsDO::getDetail, name);
    }
    default Long selectCountByParentId(Long parentId) {
        return selectCount(FloorLevelsDO::getParentId, parentId);
    }

    int selectCountByOldman(@Param("id") Long id);
}
